<template>
	<view>
	<scroll-view scroll-y class="scrollPage">
		<cu-custom bgColor="bgmain" :isBack="true">
			<view slot="content">身份认证</view>
		</cu-custom>
	</scroll-view>
	<view class="bg-color" v-if="reason && state == 2">
		<view class="bg-colors">
			<view class="text-red-title">
				拒绝原因：{{reason}}
			</view>
			</view>
			</view>
	<view class="bg-color" >
		<view class="bg-colors">
			<view class="cu-form-group margin-top">
				<view class="title"><text class="xing">*</text>姓名</view>
				<input placeholder="请输入姓名" class="inp-riget" v-model="name"></input>
			</view>
			<view class="cu-form-group">
				<view class="title"><text class="xing">*</text>联系电话</view>
				<input placeholder="请输入联系电话" class="inp-riget" v-model="phone"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">备注</view>
				<input placeholder="选填" class="inp-riget" v-model="remarks"></input>
			</view>
		</view>
	</view>
	
	<view class="buts">
		<view class="but" @click="sub">
			点击提交
		</view>
	</view>
	</view>
</template>

<script>
		import siteInfo from '@/siteinfo.js';
	var app = getApp();
	export default {
		
		data() {
			return {
				setting:[],
				images:'',
				count: 1,
				counts:1,
				name:'',
				phone:'',
				remarks:'',
				student:'',
				reason:'',
				state:'',
				dmhimage:'http://test.fkynet.net/static/img/certificates.png',
				dmgexplain:'',
				studentdmh:'',
				sys:''
			};
			},
			onLoad: function(options) {
				this.init();
				this.datas();
				this.settings();
				console.log('---')
			},
			methods: {
				settings(){
					var self = this;
					app.globalData.util.request({
					    url: 'Setting/view',
					    success(res) {
					        self.setData({
								// sysparment: res.data.data.list[0].is_anonymous_switch
					            sys: res.data.data.sys,
								dmhimage:res.data.data.sys.dmhimage,
								dmgexplain:res.data.data.sys.dmgexplain,
								studentdmh:res.data.data.sys.studentdmh,
					        });
					    }
					},true);
				},
				datas(){
					var that = this
					app.globalData.util.request({
						url: "WechatUser/dumpling_view",
						method:'POST',
						data: {
							s_id: uni.getStorageSync("schoolId")
						},
						success(res) {
							if(res.data.status == 200){
								that.name = res.data.data.name;
								that.phone = res.data.data.phone;
								that.remarks = res.data.data.notes;
							}
							// that.setting = that.escape2Html(res.data.data.sys.explains);
						}
					
					},true);
				},
				sub(){
				var that = this
				app.globalData.util.request({
					url: "WechatUser/dumpling_application",
					method:'POST',
					data: {
						s_id: uni.getStorageSync("schoolId"),
						name:this.name,
						phone:this.phone,
						notes:this.remarks,
					},
					success(res) {
							if(res.data.status){
								uni.navigateBack({
										delta:1,//返回层数，2则上上页
									})
								// uni.showToast({
								// 	title:res.data.msg,
								// 	duration:2000
								// })
							}else{
								uni.showToast({
									title:res.data.msg,
									duration:2000
								})
							}
						
					}
				
				},true);	
				},
				init(){
					var that = this
					app.globalData.util.request({
						url: "Setting/view",
						method:'POST',
						data: {
							s_id: uni.getStorageSync("schoolId")
						},
						success(res) {
							
							that.setting = that.escape2Html(res.data.data.sys.explains);
						}
					
					},true);
				},
				chooseImagesss() {
					console.log("执行几级");
					var that = this;
					uni.chooseImage({
						counts: 1,
						sizeType: ['compressed'],
						// 可以指定是原图还是压缩图，默认二者都有
						sourceType: ['album', 'camera'],
						// 可以指定来源是相册还是相机，默认二者都有
						success: function(res) {
							that.uploadimgs({
								path: res.tempFilePaths //这里是选取的图片的地址数组
							});
						}
					});
				},
				uploadimgs: function(data) {
					uni.showLoading({
						title: '上传中...',
						mask: true
					});
					console.log("上传中");
					var that = this; // console.log("打印",data.path.length)
					// var count = that.data.addedCount + data.path.length;
				
					var counts = that.addedCountss;
				
					for (var i = 0; i < data.path.length; i++) {
						// console.log("走这里")
				
						uni.uploadFile({
							// url: app.globalData.util.url() + 'c=entry&a=wxapp&do=ImgPost&m=gc_school',
							// filePath: data.path[i],
							// name: 'file',
							// formData: null,
							url: siteInfo.url + 'Base/upload',
							filePath: data.path[i],
							header: {
								'Authorization': uni.getStorageSync('token')
							},
							name: 'file',
							formData: {
								'wxapp_id': siteInfo.uniacid
							},
							success: resp => {
				
				
								var pic = JSON.parse(resp.data);
								console.log('111')
								console.log(pic.status, '---11---')
								if (pic.status == 200) {
									counts++; // console.log(pic)
									console.log('222')
									// var picList = that.picListss;
									// picList.push(pic.data); // console.log(data.path[i])
				
									// var images = that.imagesss.concat(pic.data);
									console.log('333')
									that.setData({
										images: pic.data,
										
									});
									console.log(that.addedCount);
									console.log('444')
									
										uni.hideLoading({});
									
								} else {
									uni.showToast({
										title: pic.message,
										icon: 'none'
									});
								}
							}
						});
					}
				},
			}
			};
</script>

<style>
	.bg-color {
		/* background-color: #FFFFFF; */
		width: 100%;
		/* height: 1510rpx; */
		padding: 30rpx;
		/* border-radius: 20px; */
	}

	.bg-colors {
		width: 100%;
		height: 100%;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		padding: 15rpx 0;
	}

	.inp-riget {
		text-align: right;
	}

	.xing {
		color: red;
		/* display: flex; */
		/* align-items: center; */
		margin-right: 4rpx;
	}
	.text-title{
		width: 100%;
		height: 81rpx;
		font-size: 34rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #323232;
		line-height: 48rpx;
		padding: 0 30rpx;
	}
	.text-red-title{
		width: 100%;
		height: 61rpx;
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #E82323;
		line-height: 36rpx;
		padding: 0 30rpx;
		margin-top: 24rpx;
		margin-bottom: 24rpx;
	}
	.zhengjian{
		width: 100%;
		height: 428rpx;
		padding: 30rpx;
	}
	.img{
		width: 100%;
		height: 100%;
	}
	.shuoming{
		font-size: 34rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #323232;
		line-height: 48rpx;
		padding: 0 30rpx;
	}
	.shuoming-neirong{
		/* margin-top: 30rpx; */
		padding:  30rpx;
	}
	.but{
		width: 657rpx;
		height: 88rpx;
		background: linear-gradient(90deg, #FF484A 0%, #FF716C 100%);
		box-shadow: 0rpx 6rpx 30rpx 0rpx #FF4B4C;
		border-radius: 44rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #FFFFFF;
	}
	.buts{
		width: 100%;
		height: 200rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>
